var sign = new Vue({
    el: "#app",
    data: {
        s5,
        text: 0,
        isActive: '',
        istime: '',
        img: '/static/api/images/failures.png',
        imgs: '/static/api/images/successfuls.png',
        good: [{
            sign: -1,
        }, {
            sign: -1,
        }, {
            sign: -1,
        }, {
            sign: -1,
        }, {
            sign: -1,
        }, {
            sign: -1,
        }, {
            sign: -1,
        },],

    },
    onload: {},
    //计算属性
    computed: {},
    //监听属性
    watch: {},
    //钩子函数
    created() {
    },
    mounted() {
        this.signRecord();
    },
    methods: {
        signIn() {
            this.signRecord();
            var that = this
            s5.initData({
                url: '/sign',
                type: 'post',
                // data: {
                //     sign_time: 1617811200 //传给后端时间戳
                // },
            }, (res) => {
                var res = JSON.parse(res)
                console.log('返回', res)
                if (res.code == -1) {
                    weui.confirm(res.msg, {
                        title: '温馨提示',
                        buttons: [{
                            label: '确定',
                            type: 'default',
                            onClick: function () {
                                console.log('确定')
                            }
                        },]

                    });
                }

            });

        },
        severalWeeks(e) {
            console.log(e)
            if (e > this.istime) {
                return
            }
            if (e < this.istime) {
                // this.text = '立即补签'
            } else {
                // this.text = '立即签到'
                // this.signRecord();
            }
            //
            if (e == 1) {
                this.isActive = 1
            }
            if (e == 2) {
                this.isActive = 2
            }
            if (e == 3) {
                this.isActive = 3
            }
            if (e == 4) {
                this.isActive = 4
            }
            if (e == 5) {
                this.isActive = 5
            }
            if (e == 6) {
                this.isActive = 6
            }
            if (e == 7) {
                this.isActive = 7
            }
        },
        signRecord() {
            var that = this
            s5.initData({
                url: '/sign-record',
                type: 'post',
            }, (res) => {
                var res = JSON.parse(res)
                //获取今天周几
                var zhouji = "0123456".charAt(new Date().getDay());
                console.log('周几', zhouji)
                this.isActive = zhouji
                this.istime = zhouji
                // 大于今天的赋值为0
                for (var i = zhouji - 1; i < this.good.length; i++) {
                    this.good[i].sign = 0
                }
                console.log('签到记录', res)
                var week = res.data.list[0].week
                var list = res.data.list
                for (var i = 0; i < list.length; i++) {
                    console.log('-', list[i].week)
                    // 下标为list[i].week]的sign赋值为1
                    this.good[list[i].week].sign = 1
                }
            });

        },
        go() {//绑卡go
            console.log('go')
        }
    }

})
